// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.

package json类

import (
	gfile "github.com/gogf/gf/v2/os/gfile"
)

// Load loads content from specified file `path`, and creates a Json object from its content.
// Deprecated: use LoadPath instead.
func X加载文件(路径 string, 并发安全 ...bool) (*X结构_Json, error) {
	var isSafe bool
	if len(并发安全) > 0 {
		isSafe = 并发安全[0]
	}
	return X加载文件并按选项(路径, X结构_选项{
		Safe: isSafe,
	})
}

// LoadPath 从指定的文件 path 中加载内容，并根据该内容创建一个 Json 对象
func X加载文件并按选项(路径 string, 选项 X结构_选项) (*X结构_Json, error) {
	if p, err := gfile.Search(路径); err != nil {
		return nil, err
	} else {
		路径 = p
	}
	if 选项.Type == "" {
		选项.Type = X类型_ContentType(gfile.Ext(路径))
	}
	return loadContentWithOptions(gfile.GetBytesWithCache(路径), 选项)
}
